package com.easyexcel.demo.exception;

import cn.hutool.core.util.ArrayUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 响应枚举
 */
@Getter
@AllArgsConstructor
public enum ResponseEnum {

    SUCCESS(200, "请求成功"),
    PARAM_ERROR(400, "参数异常"),
    SERVER_ERROR(500, "请求异常"),
    BUSINESS_EXCEPTION(500, "业务异常");

    private final Integer code;
    private final String msg;

    /**
     * 根据编码查找枚举
     */
    public static ResponseEnum valueOf(Integer value) {
        return ArrayUtil.firstMatch(v -> v.getCode().equals(value), ResponseEnum.values());
    }

}
